Skip to content

Auto-append .git suffix for GitHub/GitLab URLs missing it#225

Merged
swissspidy merged 10 commits intomainfrom
copilot/add-git-suffix-automatically
Mar 3, 2026
Merged

Auto-append .git suffix for GitHub/GitLab URLs missing it#225
swissspidy merged 10 commits intomainfrom
copilot/add-git-suffix-automatically

Conversation

Copy link
Contributor

Copilot AI commented Mar 2, 2026

wp package install only recognized a URL as a git repository if it ended with .git, silently failing for standard GitHub/GitLab URLs without that suffix.

Changes

  • maybe_add_git_suffix() method — normalizes GitHub/GitLab HTTPS and SSH URLs by appending .git if absent, before any further processing. Supports nested GitLab group paths (e.g. https://gitlab.com/group/subgroup/repo).
  • Called early in install() — runs before version suffix parsing and is_git_repository() check, so all downstream logic operates on an already-normalized URL.
  • GitHub-only default branch detectionget_github_default_branch() is now only called for GitHub URLs; non-GitHub git repos (e.g. GitLab) default to dev-master instead of making a failing GitHub API call.
# These now work identically to their .git equivalents:
wp package install https://github.com/wp-cli/google-sitemap-generator-cli
wp package install https://github.com/wp-cli/google-sitemap-generator-cli:dev-main
wp package install git@github.com:wp-cli/google-sitemap-generator-cli
wp package install https://gitlab.com/group/subgroup/repo

Both HTTPS and SSH formats are handled for both GitHub and GitLab. Version suffixes (:dev-main) are preserved during normalization.

Tests

Added four Behat scenarios covering the new behavior:

  • Install from a bare GitHub HTTPS URL (no .git)
  • Install from a GitHub HTTPS URL with a version suffix but no .git
  • Install from a GitHub SSH URL without .git
  • Install from a GitLab HTTPS URL with nested groups and no .git
Original prompt

This section details on the original issue you should resolve

<issue_title>Determine if git from prefix also and add .git suffix if not there.</issue_title>
<issue_description>Currently a package is determined to be a git only if the .git extension is present.

If given a standard github url like https://github.com/wp-cli-test/repository-name (or its ssh equivalent) without the .git suffix then it should also determine it to be a git package and append the .git suffix automatically.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@swissspidy swissspidy added the command:package-install Related to 'package install' command label Mar 2, 2026
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Determine if git prefix and append .git suffix Auto-append .git suffix for GitHub/GitLab URLs missing it Mar 2, 2026
@swissspidy swissspidy requested a review from Copilot March 3, 2026 09:19
@swissspidy

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

This comment was marked as resolved.

swissspidy and others added 2 commits March 3, 2026 10:36
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…st expectation

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy swissspidy marked this pull request as ready for review March 3, 2026 12:47
@swissspidy swissspidy requested a review from a team as a code owner March 3, 2026 12:47
@swissspidy swissspidy added this to the 2.6.2 milestone Mar 3, 2026
@swissspidy swissspidy merged commit f5dbb0e into main Mar 3, 2026
68 checks passed
@swissspidy swissspidy deleted the copilot/add-git-suffix-automatically branch March 3, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:package-install Related to 'package install' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Determine if git from prefix also and add .git suffix if not there.

3 participants